<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h2>扩展运算符和剩余参数</h2>
</body>
<script>
    //1.扩展运算符应用 ...
    let arr1 = ['vue', 'react', 'angular']
    let arr2 = ['微信小程序', 'uniapp']
        //如何实现合并数组
    let result = [...arr1, ...arr2]
        // console.log(result)

    let obj1 = {
        name: '张三',
        age: 20
    }

    let obj2 = {
        address: '北京'
    }
    let result2 = {...obj1,
        ...obj2
    }

    // console.log(result2)

    //2.剩余参数
    function sum(title, ...a) {
        return a.reduce((acc, cur) => acc + cur)
            // let res = 0;
            // for (let i = 1; i < arguments.length; i++) {
            //     res += arguments[i]
            // }

        // return res;
    }

    console.log(sum('求和：', 1, 2, 3, 4, 5, 6))
</script>

</html>